<?php
/**
 * 这里是登录操作
 * 
 * @author jerry
 * @version $Id$
 * @package model
 *
 */

class Login extends Controller  
{
	/**
	 * 解析函数
	 *
	 */
	function __construct()
	{
		parent::__construct();
		
		$this->loadModel('Login_model');
	}
	
	/**
	 * 用户登录
	 *
	 */
	function login()
	{
		if($this->in_var['request_method'] == 'post')
		{
			if(empty($this->in_var['User']))
			{
				goto('index.php?c=login&d=login&msg=' . urlencode('请输入用户名'),'js');
			}
			
			if(empty($this->in_var['Pass']))
			{
				goto('index.php?c=login&d=login&msg=' . urlencode('请输入密码'),'js');
			}
			
			if($this->login_model->login($this->in_var['User'],$this->in_var['Pass']))
			{
				goto('index.php');
			}
			else 
			{
				goto('index.php?c=login&d=login&msg=' . urlencode('用户名或密码不正确'),'js');
			}
		}
		else 
		{
			$this->tpl->assign('Msg',$this->in_var['msg']);
			$this->tpl->display('login.html');    //指定模板
		}
	}
	
	/**
	 * 用户退出
	 *
	 */
	function logout()
	{
		$this->login_model->delSession();

		goto('index.php','js','top');
	}
	
}